(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/script/MyScene.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, '51e7bKbOY1AFLNPoJsY8grr', 'MyScene', __filename);
// script/MyScene.js

"use strict";

// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
var Global = require("Global");

cc.Class({
    extends: cc.Component,

    properties: {
        titleLabel: {
            default: null,
            type: cc.Label
        }
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad: function onLoad() {
        Global.mySceneCount++;
        if (this.titleLabel) {
            this.titleLabel.string = "MyScene " + Global.mySceneCount;
        }

        this.loadRes2();
    },
    start: function start() {},


    // update (dt) {},

    onBackBtnClick: function onBackBtnClick() {
        cc.director.loadScene("game");
    },
    loadRes1: function loadRes1() {
        var animation = this.getComponent(cc.Animation);
        cc.loader.loadRes("test_resources/atlas", cc.SpriteAtlas, function (err, atlas) {
            var spriteFrames = atlas.getSpriteFrames();

            var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10);
            clip.name = 'run';
            clip.wrapMode = cc.WrapMode.Loop;

            animation.addClip(clip);
            animation.play('run');
        });
    },


    // 动态加载资源
    loadRes2: function loadRes2() {
        var _this = this;

        cc.loader.loadRes("test_resources/atlas", cc.SpriteAtlas, function (err, atlas) {
            var frame = atlas.getSpriteFrame('sheep_run_0');

            var node = new cc.Node('Sprite');
            var sprite = node.addComponent(cc.Sprite);
            sprite.spriteFrame = frame;
            // 添加节点到当前组件中
            // node.parent = this; // 不能直接使用this，需要使用node属性获取当前组件附加到的节点
            // 参考文档：http://docs.cocos.com/creator/api/zh/classes/Component.html
            node.parent = _this.node;
        });
    }
});

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=MyScene.js.map
        